let baseURL = '';
process.env.baseURL && (baseURL = process.env.baseURL);

export function get(url) {
    return new RegExp(baseURL + url + '(\\?.*|(?![\\s\\S]))');
}

export function post(url) {
    return baseURL + url;
}

export function qsUrl(url) {
    var pos = url.indexOf('?'),
        qs = pos !== -1 ? url.substring(pos + 1) : '',
        args = {},
        items = qs.length ? qs.split('&') : [],
        item = null,
        name = null,
        value = null,
        i = 0,
        len = items.length;
    for (i = 0; i < len; i++) {
        item = items[i].split('=');
        name = decodeURIComponent(item[0]);
        value = decodeURIComponent(item[1]);
        if (name.length) {
            args[name] = value;
        }
    }
    return args;
}